package com.qys.livesMall.shop.enums;

import com.qys.livesMall.shop.event.OpenShopEvent;
import com.qys.livesMall.shop.event.handle.BaseHandler;
import com.qys.livesMall.shop.event.handle.service.*;
import com.qys.livesMall.shop.event.shop.pojo.*;

import java.util.Objects;


public enum ShopEventTypeEnum {

    SHOP_OPEN_SUCCESS("sos",  ShopBaseServer.class, OpenShopEventPojo.class),
    SHOP_R_W_SUCCESS("srw", ShopReWlServer.class, OpenShopEventPojo.class),

    SHOP_ORDER("sor", ShopOrderServer.class, ShopOrderPojo.class),
    SHOP_INCOME("sie", ShopIncomeServer.class, ShopIncomePojo.class),
    SHOP_WAIT_WL("sww", ShopWaitWlServer.class, ShopWaitWlPojo.class),
    SHOP_STOCKS("ss", ShopStocksServer.class, ShopStocksPojo.class),

;
    private String type;

    private Class<? extends BaseHandler> event;

    private Class paramObj;



    public String getType() {
        return type;
    }

    public Class getEvent() {
        return event;
    }

    public Class getParamObj() {
        return paramObj;
    }

    ShopEventTypeEnum(String type, Class eventClass, Class pojoClass) {
        this.type=type;
        this.event=eventClass;
        this.paramObj=pojoClass;
    }

    public static ShopEventTypeEnum getByType(String type){
        for(ShopEventTypeEnum eventTypeEnum:ShopEventTypeEnum.values()){
            if (Objects.equals(eventTypeEnum.type,type)){
                return eventTypeEnum;
            }
        }
        return null;
    }

}
